/*
 * @Author: **
 * @Description: 12
 * @Version: 2.0
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-12-11 11:47:36
 */
import elementResizeDector from 'element-resize-detector'
const resizeDector = elementResizeDector()

export default {
    // 绑定监听器，监听元素的宽高
    bind(el, binding) {
        console.log(el, binding, '----element');
        el._handleResize = function (el) {
            binding.value({
                el: el,
                width: el.offsetWidth,
                height: el.offsetHeight
            })
        }
        resizeDector.listenTo(el, el._handleResize)
    },
    // 解绑
    unbind(el) {
        console.log(el, '--unbind--element');

        resizeDector.removeListener(el, el._handleResize)
    }
}
export {
    resizeDector
}
